<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script type="text/javascript">
	$(document).ready(function(){
		$("#view_origin").hide();
		$("#r_uploadFile").attr("src","${initParam.imgRoot}${sessionScope.recipeContent.rvo.r_img_new}");
		$("#main_arrow_next").click(function(){
		    $(":hidden[name=pageNo]").val($("#now_pageNo").text());
			$("#pForm_1").submit();
		});
		//처음 페이지 이기 때문에 alert창을 띄움
		$("#main_arrow_prev").click(function(){
			alert("처음 페이지 입니다");
		});
		//이미지 클릭시 레이어팝업으로 원본이미지 띄우기
		$("#r_uploadFile").click(function(){
			$("#view_origin").show();
		});
		//레이어팝업 이미지 클릭시 hide
		$("#img_origin").click(function(){
			$("#view_origin").hide();
		});
		$("#main_cancle").click(function(){
			//&r_no=${sessionScope.recipeContent.rvo.r_no}
			if(confirm("수정 하시겠습니까?")){
				location.href="recipe.do?command=update_move&page=1";
			}
		});
		//삭제버튼
		$("#main_ok").click(function(){
			 if(confirm("이 게시물을 삭제하시겠습니까?")){
			    location.href="recipe.do?command=delete&r_no=${sessionScope.recipeContent.rvo.r_no}";
			 }
		});
		//최초 즐겨 찾기 버튼 이미지 판단- 비로그인시와, 즐겨찾기를 이미 했는지 안했는지 판단
		if(${requestScope.favorite_flag==null}||${requestScope.favorite_flag==false}){
			$("#favoriteBtn").attr("src","${initParam.root }/img/main/main-favorite-btn.png");
		}else if(${requestScope.favorite_flag==true}){
			$("#favoriteBtn").attr("src","${initParam.root }/img/main/main-favorite-btn2.png");
		}
		//즐겨찾기 버튼 누를시 판단
		$(".favorite").toggle(function(){
			if(${sessionScope.loginMember==null}){
				alert("즐겨찾기는 로그인을 하셔야합니다.");
			}else if(${requestScope.favorite_flag==false}){
				if(confirm("즐겨찾기에 추가 하시겠습니까?")){
					location.href="recipe.do?command=addFavorite&r_no=${sessionScope.recipeContent.rvo.r_no}&m_id=${sessionScope.recipeContent.rvo.m_id}&reply_flag="+$("#reply_flag").val();
				}
			}else if(${requestScope.favorite_flag==true}){
				if(confirm("즐겨찾기를 삭제하시겠습니까?")){
					location.href="recipe.do?command=deleteFavorite&r_no=${sessionScope.recipeContent.rvo.r_no}&m_id=${sessionScope.recipeContent.rvo.m_id}&reply_flag="+$("#reply_flag").val();
				}
			}
		},
		function(){
			if(${sessionScope.loginMember==null}){
				alert("즐겨찾기는 로그인을 하셔야합니다.");
			}else if(${requestScope.favorite_flag==false}){
				if(confirm("즐겨찾기에 추가 하시겠습니까?")){
					location.href="recipe.do?command=addFavorite&r_no=${sessionScope.recipeContent.rvo.r_no}&m_id=${sessionScope.recipeContent.rvo.m_id}&reply_flag="+$("#reply_flag").val();
				}
			}else if(${requestScope.favorite_flag==true}){
				if(confirm("즐겨찾기를 삭제하시겠습니까?")){
					location.href="recipe.do?command=deleteFavorite&r_no=${sessionScope.recipeContent.rvo.r_no}&m_id=${sessionScope.recipeContent.rvo.m_id}&reply_flag="+$("#reply_flag").val();
				}
			}
		});
		
	});
</script>
<style type="text/css">
	#main_subject_text{
		text-align: center;
		border: none;
	}
	#main_content_text{
		text-align: center;
		border: none;
	}
	.attendFont{
		position:absolute;
		font-size: 13pt;
		font-family: HY얕은샘물M;
		top: 30px;
		left:55px;
	}
	.dateRecipe{
		position:absolute;
		top: 585px;
		left:900px;
		font-size: 17px;
		font-family: HY얕은샘물M;
		color: #c1c1c1;
	}
	.writerRecipe{
		position:absolute;
		top: 442px;
		left:690px;
		font-size: 17px;
		font-family: HY얕은샘물M;
		color: black;
	}
</style>
<div id="write_container">
<!-- 즐겨찾기 버튼 -->
<div class="favorite">
<img id="favoriteBtn" src="${initParam.root }/img/main/main-favorite-btn.png" style="cursor: pointer;">
</div>
<!-- 작성자,날짜 -->
<div class="writerRecipe">작성자 ${sessionScope.recipeContent.rvo.r_writer }</div>
<div class="dateRecipe">${sessionScope.recipeContent.rvo.r_date }</div>
<input type="hidden" name="showReplyBtn" value="true">
<div id="main_page1"><img src="${initParam.root }/img/main/main-write-page1.gif"></div>
<div id="main_arrow_prev"><input type="image" src="${initParam.root }/img/main/main-write-prev.gif"></div>
<div id="main_arrow_next"><input type="image" src="${initParam.root }/img/main/main-write-next.gif"></div>

<c:if test="${sessionScope.recipeContent.rvo.m_id==sessionScope.loginMember.mvoLogin.m_id}">
<div id="main_cancle"><input type="image" src="${initParam.root }/img/main/main-update-btn.gif"></div>
<div id="main_ok"><input type="image" src="${initParam.root }/img/main/main-delete-btn.gif"></div>
</c:if>
	<div id="main_write_form">
 		<form id="pForm_1" action="recipe.do" method="post">
 		<input type="hidden" name="command" value="getContent">
 		<input type="hidden" name="page" value="2">
 		<input type="hidden" name="pageNo" value="">
 		<input id="reply_flag" type="hidden" name="reply_flag" value="${requestScope.reply_flag}">
	 		<div id="main_title"><input type="text" id="main_subject_text" name="r_title" value="${sessionScope.recipeContent.rvo.r_title}"  readonly="readonly"/></div>
	 			<div id="main_img" align="center"><img src="${initParam.root }/img/main/main-write-img.jpg" name="r_uploadFile" id="r_uploadFile" style="cursor: pointer;"></div>
	 		<div id="main_comment"><pre><textarea id="main_content_text" align="middle" cols="75" rows="7" name="r_comment" readonly="readonly">${sessionScope.recipeContent.rvo.r_comment}</textarea></pre></div>
 		</form>
 	</div>
 <span class="attendFont">
				<c:choose>
						<c:when test="${sessionScope.recipeContent.rvo.r_gcnt>0 }">
						
							<c:if test="${sessionScope.recipeContent.rvo.r_grade >4.5}">
							 <img alt="grade" src="${initParam.root }/img/main/grade/contents-grade-5.png">
      						</c:if>
							<c:if test="${sessionScope.recipeContent.rvo.r_grade >=4.5 and sessionScope.recipeContent.rvo.r_grade <5}">
									 <img alt="grade" src="${initParam.root }/img/main/grade/contents-grade-4.5.png">
      						</c:if>
      							<c:if test="${sessionScope.recipeContent.rvo.r_grade >=4 and sessionScope.recipeContent.rvo.r_grade<4.5}">
									 <img alt="grade" src="${initParam.root }/img/main/grade/contents-grade-4.png">
      						</c:if>
      						<c:if test="${sessionScope.recipeContent.rvo.r_grade >=3.5 and sessionScope.recipeContent.rvo.r_grade<4}">
      							<img alt="grade" src="${initParam.root }/img/main/grade/contents-grade-3.5.png">
      						</c:if>
      							<c:if test="${sessionScope.recipeContent.rvo.r_grade >=3 and sessionScope.recipeContent.rvo.r_grade<3.5}">
      							<img alt="grade" src="${initParam.root }/img/main/grade/contents-grade-3.png">
      						</c:if>
      							<c:if test="${sessionScope.recipeContent.rvo.r_grade >=2.5 and sessionScope.recipeContent.rvo.r_grade<3}">
      							<img alt="grade" src="${initParam.root }/img/main/grade/contents-grade-2.5.png">
      						</c:if>
      							<c:if test="${sessionScope.recipeContent.rvo.r_grade >=2 and sessionScope.recipeContent.rvo.r_grade<2.5}">
      							<img alt="grade" src="${initParam.root }/img/main/grade/contents-grade-2.png">
      						</c:if>
      						<c:if test="${sessionScope.recipeContent.rvo.r_grade >=1.5 and sessionScope.recipeContent.rvo.r_grade<2}">
      							<img alt="grade" src="${initParam.root }//img/main/grade/contents-grade-1.5.png">
      						</c:if>
      						<c:if test="${sessionScope.recipeContent.rvo.r_grade >=1 and sessionScope.recipeContent.rvo.r_grade<1.5}">
      							<img alt="grade" src="${initParam.root }/img/main/grade/contents-grade-1.png">
      						</c:if>
      						<c:if test="${sessionScope.recipeContent.rvo.r_grade >=0.5 and sessionScope.recipeContent.rvo.r_grade<1}">
      							<img alt="grade" src="${initParam.root }/img/main/grade/contents-grade-1.png">
      						</c:if>
      						<c:if test="${sessionScope.recipeContent.rvo.r_grade>0 and sessionScope.recipeContent.rvo.r_grade<0.5}">
      							<img alt="grade" src="${initParam.root }/img/main/grade/contents-grade-0.5.png">
      						</c:if>
      						</c:when>
							<c:otherwise>
								<img alt="grade" src="${initParam.root }/img/main/grade/contents-grade-0.png">
							</c:otherwise>
							</c:choose>
					<b>${sessionScope.recipeContent.rvo.r_gcnt}명참여</b></span>
</div>
<div id="view_origin" align="center" style="position: absolute; width:1024px; top:10px; vertical-align:middle;">
	<img src="${initParam.imgRoot }${sessionScope.recipeContent.rvo.r_img_origin}" style="max-width:1024px; height:768px; width: auto; cursor: pointer;" id="img_origin">
</div>